/**
 * 游戏通用玩法介绍页面
 */
module game {
    export class GameHelpMediator extends BaseMediator {
        public static NAME: string = "GameHelpMediator";

        public constructor(viewComponent: any = null) {
            super(GameHelpMediator.NAME, viewComponent);
        }
        public listNotificationInterests(): Array<any> {
            return [
                PanelNotify.HALL.STAGE_RESIZE,
                PanelNotify.HALL.OPEN_HELP_BRNN,
                PanelNotify.HALL.OPEN_HELP_PHB,
                PanelNotify.HALL.OPEN_HELP_DDZ,
                PanelNotify.HALL.OPEN_HELP_HLSZ,
                PanelNotify.HALL.OPEN_HELP_QZNN,
                PanelNotify.HALL.OPEN_HELP_WJL,
                PanelNotify.HALL.OPEN_HELP_LHD,
                PanelNotify.HALL.OPEN_HELP_HHDZ,
                PanelNotify.HALL.OPEN_HELP_BREBG,
                PanelNotify.HALL.CLOSE_HELP,
            ];
        }
        private panel: GameHelpPanel;
        public handleNotification(notification: puremvc.INotification): void {
            var data: any = notification.getBody();
            switch (notification.getName()) {
                case PanelNotify.HALL.STAGE_RESIZE:
                    if (this.panel) {
                        this.panel.width = GameConfig.curWidth()
                        this.panel.height = GameConfig.curHeight()
                    }
                    break;
                case PanelNotify.HALL.OPEN_HELP_BRNN:
                    this.openUI(InstructionsEnum.GAME_TYPE_NAME.BRNN);
                    break;
                case PanelNotify.HALL.OPEN_HELP_PHB:
                    this.openUI(InstructionsEnum.GAME_TYPE_NAME.PHB);
                    break;
                case PanelNotify.HALL.OPEN_HELP_DDZ:
                    this.openUI(InstructionsEnum.GAME_TYPE_NAME.DDZ);
                    break;
                case PanelNotify.HALL.OPEN_HELP_HLSZ:
                    this.openUI(InstructionsEnum.GAME_TYPE_NAME.HLSZ);
                    break;
                case PanelNotify.HALL.OPEN_HELP_QZNN:
                    this.openUI(InstructionsEnum.GAME_TYPE_NAME.QZNN);
                    break;
                case PanelNotify.HALL.OPEN_HELP_WJL:
                    this.openUI(InstructionsEnum.GAME_TYPE_NAME.WJL);
                    break;
                case PanelNotify.HALL.OPEN_HELP_LHD:
                    this.openUI(InstructionsEnum.GAME_TYPE_NAME.LHD);
                    break;
                case PanelNotify.HALL.OPEN_HELP_HHDZ:
                    this.openUI(InstructionsEnum.GAME_TYPE_NAME.HHDZ);
                    break;
                case PanelNotify.HALL.OPEN_HELP_BREBG:
                    this.openUI(InstructionsEnum.GAME_TYPE_NAME.BREBG);
                    break;
                case PanelNotify.HALL.CLOSE_HELP:
                    this.closePanel(0);
                    break;
            }
        }
        public initUI(): void {
            this.panel.closeBtn.addEventListener(egret.TouchEvent.TOUCH_TAP, this.Close, this)
        }
        public initData(): void {

        }
        private imgArr = {
            brnn: ["help_brnn_1", "help_brnn_2", "help_brnn_3", "help_brnn_4",],
            bjl: ["help_bjl_1", "help_bjl_2", "help_bjl_3"],
            ddz: ["help_ddz_1", "help_ddz_2", "help_ddz_3", "help_ddz_4"],
            hlsz: ["help_hlsz_1", "help_hlsz_2", "help_hlsz_3"],
            lhd: ["help_lhd_1", "help_lhd_2"],
            qznn: ["help_qznn_1", "help_qznn_2", "help_qznn_3", "help_qznn_4"],
            hhdz: ["help_hhdz_1", "help_hhdz_2"],
            brebg: ["help_brebg_1", "help_brebg_2"],
            phb: ["help_phb_1"]

        }
        private openUI(gameType: string) {
            this.panel = null;
            this.panel = new GameHelpPanel();
            this.showUI(this.panel, 2, 1, true);
            var arr: Array<string>
            switch (gameType) {
                case InstructionsEnum.GAME_TYPE_NAME.PHB:
                    arr = this.imgArr.phb
                    break;
                case InstructionsEnum.GAME_TYPE_NAME.BRNN:
                    arr = this.imgArr.brnn
                    break;
                case InstructionsEnum.GAME_TYPE_NAME.DDZ:
                    arr = this.imgArr.ddz
                    break;
                case InstructionsEnum.GAME_TYPE_NAME.HLSZ:
                    arr = this.imgArr.hlsz
                    break;
                case InstructionsEnum.GAME_TYPE_NAME.QZNN:
                    arr = this.imgArr.qznn
                    break;
                case InstructionsEnum.GAME_TYPE_NAME.WJL:
                    arr = this.imgArr.bjl
                    break;
                case InstructionsEnum.GAME_TYPE_NAME.LHD:
                    arr = this.imgArr.lhd
                    break;
                case InstructionsEnum.GAME_TYPE_NAME.HHDZ:
                    arr = this.imgArr.hhdz
                    break;
                case InstructionsEnum.GAME_TYPE_NAME.BREBG:
                    arr = this.imgArr.brebg
                    break;
            }
            this.panel.imgGroup.removeChildren();
            for (var i in arr) {
                this.panel.imgGroup.addChild(new eui.Image(arr[i]))
            }
        }



        private Close(): void {
            SoundManage.startAnniuBtnLoad();
            this.closePanel(1);
        }
    }
}